package us.kg.kotoriforest.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 测试restful风格
 *
 * @author Kotori rotroutine@163.com
 * @since 2025/1/19
 */
@Controller
public class UserController {
    @GetMapping("/user")
    public String getAllUsers() {
        System.out.println("查询全部用户信息");
        return "success";
    }

    @GetMapping("/user/{id}")
    public String getUserById(@PathVariable("id") int id) {
        System.out.println("获取id为" + id + "的用户信息");
        return "success";
    }

    @PostMapping("/user")
    public String addUser(@RequestParam("username") String username, @RequestParam("password") String password) {
        System.out.println("username:" + username + " password:" + password);
        return "success";
    }

    @PutMapping("/user")
    public String updateUser(@RequestParam("username") String username, @RequestParam("password") String password) {
        System.out.println("username:" + username + " password:" + password);
        return "success";
    }

    @DeleteMapping("/user/{id}")
    public String deleteUser(@PathVariable("id") int id) {
        System.out.println("delete id:" + id);
        return "success";
    }
}
